<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a><cite>订单管理</cite></a>
    <a><cite>订单设置</cite></a>
  </div>
</div>

<script>
  var settings_url = 'agent-admin/settings';
</script>
<script type="text/html" template lay-url="{{settings_url}}" lay-done="layui.data.done(d.data)">
  <div class="layui-fluid layui-form">
    <div class="layui-form">
      {{# var settings = d.data }}
      <div class="layui-card">
        <div class="layui-card">
          <div class="layui-card-header">
           锁单时间
          </div>
          <div class="layui-card-body">
            <div class="layui-form-item">
              <div class="layui-inline form-required">未支付订单超过</div>
              <div class="layui-inline" style="width: 100px">
                <input type="number" autocomplete="off" class="layui-input" lay-verify="required"
                       name="order_lock_minutes" value="{{settings.order_lock_minutes || 10}}">
              </div>
              <div class="layui-inline">分钟则自动取消（默认为10分钟）</div>
            </div>
          </div>
        </div>
        <div class="layui-card-header">
          锁单惩罚
        </div>
        <div class="layui-card-body">
          <div class="layui-form-item">
            <div class="layui-inline form-required">发行订单取消超过</div>
            <div class="layui-inline" style="width: 100px">
              <input type="number" autocomplete="off" class="layui-input" lay-verify="required"
                     name="order_daily_cancel_limit" value="{{settings.order_daily_cancel_limit || 0}}">
            </div>
            <div class="layui-inline">次后当天禁止下单 (设为0表示不做限制)</div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline form-required">转售订单取消超过</div>
            <div class="layui-inline" style="width: 100px">
              <input type="number" autocomplete="off" class="layui-input" lay-verify="required"
                     name="resale_order_daily_cancel_limit" value="{{settings.resale_order_daily_cancel_limit || 0}}">
            </div>
            <div class="layui-inline">次后当天禁止下单 (设为0表示不做限制)</div>
          </div>
        </div>
      </div>
      <div class="layui-card">
        <div class="layui-card-header">
          钱包
        </div>
        <div class="layui-card-body">
          <div class="layui-form-item">
            <div class="layui-inline form-required">开通钱包需支付</div>
            <div class="layui-inline" style="width: 100px">
              <input type="number" autocomplete="off" class="layui-input" lay-verify="required"
                     name="open_wallet_fee" value="{{settings.open_wallet_fee || 0}}">
            </div>
            <div class="layui-inline">元（设为0表示不收费）</div>
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-footer">
          <div class="layui-input-block">
            <input type="button" lay-submit lay-filter="submit_settings" value="保存"
                   class="layui-btn">
          </div>
        </div>
      </div>
    </div>
  </div>
</script>
<script>
  layui.data.done = function (obj) {
    layui.use([], function () {
      let form = layui.form
        , admin = layui.admin

      // 提交
      form.on('submit(submit_settings)', function (data) {
        let field = data.field;
        console.log(field)
        admin.post(settings_url, field, function () {
          layer.msg('保存成功', {
            offset: '15px'
            , icon: 1
            , time: 1000
          });
        });
      });
    });
  }
</script>
